home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / LPD / src / LPD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-14  |  741 b   |  43 lines

  1.  
  2. #include "RJS/Transport.h"
  3. #include "LPD.h"
  4.  
  5. RJS_LPD::RJS_LPD(RJS_String h, RJS_String q)
  6. {
  7.     host=h;
  8.     queue=q;
  9.     lpd_address.lookup(host,"printer","tcp");
  10. }
  11.  
  12. RJS_LPD::set_queue(RJS_String h, RJS_String q)
  13. {
  14.     host=h;
  15.     queue=q;
  16.     lpd_address.lookup(host,"printer","tcp");
  17. }
  18.  
  19. RJS_String RJS_LPD::status(RJS_String user_or_job, int long_flag)
  20. {
  21.  
  22.   lpd_server.reserved_socket(1023);
  23.   lpd_server.connect(lpd_address);
  24.  
  25.   RJS_String command;
  26.   if (long_flag) command = '\04'; else command = '\03';
  27.  
  28.   command += queue + user_or_job + '\n';
  29.   lpd_server.write(command,command.length());
  30.  
  31.   int nbr;
  32.   RJS_String result;
  33.   char buffer[512];
  34.  
  35.   while(nbr=lpd_server.read(buffer,512)) {
  36.       buffer[nbr]=0;    
  37.       result += buffer;
  38.   }
  39.  
  40.   return result;
  41. }
  42.  
  43.